/**
   A class to process names.
*/
public class Names
{
   /**
      Turns a name "First Last" into a name "Last, First"
      @param firstLast a name such as "Harry Smith", with a space separating
      the first and last name.
      @return a name such as "Smith, Harry", with the last name followed by
      a comma, a space, and the first name.
   */
   public String getLastFirst(String firstLast)
   {
      int i,a;
      String f="";
      for(i=0;i<firstLast.length();i++){
         if(firstLast.charAt(i)==' '){
            break;
         }
      }
      a=i;
      for(int j=a+1;j<firstLast.length();j++){
         char first=firstLast.charAt(j);
         f=f+first;
      }
      f=f+", ";
      for(int p=0;p<a;p++){
         char last=firstLast.charAt(p);
         f=f+last;
      }
      return f;
   }
}
